<script setup lang="ts">
	import useLogStore from '@/stores/log'
	import LogMylog from '@/components/Log/LogMylog.vue'
	import LogFilter from '@/components/Mylog/LogFilter.vue'
	const Mylog = useLogStore().mylog

	Mylog.getLogs()

	onReachBottom(() => {
		if (!Mylog.loading) Mylog.addLogs()
	})

	const tab = reactive({
		cur: 0,
		tabs: ['时间线', '待办', '日历', '地图', '相册'],
		switch: ({ currentIndex } : { currentIndex : number }) => {
			if (tab.cur !== currentIndex) tab.cur = currentIndex
		}
	})
</script>

<template>
	<view class="mylog">
		<NavBar>
			<view class="nav-bar">
				<!-- <view class="page-name">记录</view> -->
				<view class="tabs">
					<uni-segmented-control :current="tab.cur" :values="tab.tabs" style-type="text" active-color="#D56556"
						@clickItem="tab.switch" />
				</view>
			</view>
		</NavBar>

		<view v-if="tab.cur === 0" class="main mylog">
				<LogFilter />
			<LogMylog v-for="log in Mylog.list" :log="log" :key="log.id" />
			<u-loadmore :status="Mylog.loading ? 'loading' : (Mylog.noMore ? 'nomore' : 'loadmore')" />
		</view>
		<view v-if="tab.cur === 1" class="main"><text>选项卡2的内容</text></view>
		<view v-if="tab.cur === 2" class="main"><text>选项卡3的内容</text></view>
		<view v-if="tab.cur === 3" class="main"><text>选项卡3的内容</text></view>
	</view>

</template>

<style scoped lang="scss">
	.mylog {
		& {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}

		.main {
			margin-top: $gap;
			display: flex;
			flex-direction: column;
			width: 100vw;
			gap: $gap;
		}

		.nav-bar {
			padding: 0 100rpx;
			width: 100%;
			display: flex;
			flex-direction: row;
			align-items: flex-end;
			gap: 32rpx;
			height: 80rpx;

			// .page-name {
			// 	margin-left: 24rpx;
			// 	font-size: 40rpx;
			// 	font-weight: bold;
			// }

			.tabs {
				flex: 1;
			}
		}
	}
</style>